package main

import (
	"family/model"
	"family/pkg/db"
	"family/router"
	"fmt"
	"net"

	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
)

func main() {
	engine := gin.Default()
	engine.SetTrustedProxies(nil)

	//CORS跨域配置
	config := cors.DefaultConfig()
	config.AllowAllOrigins = true
	config.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "token"}
	engine.Use(cors.New(config))
	interfaces, err := net.InterfaceAddrs()
	if err != nil {
		return
	}
	for i, item := range interfaces {
		fmt.Println(i, ":", item.(*net.IPNet))
	}
	router.Router(engine)
	db.DB.AutoMigrate(&model.Spouse{}, &model.People{}, &model.Event{}, &model.User{})
	engine.Run(":8080")
}
